Part Number Hot Search : 
YUNPR 2N700 1533SY SLD9630 200BG 1533SY 5248B R5F2136
Product Description
Full Text Search
 

To Download AN2604 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  august 2007 rev 1 1/14 AN2604 application note stm32f101xx and stm32f103xx rtc calibration introduction the real-time clock (rtc) precision is a requirement in most embedded applications, but due to external environment ? temperature change, frequency variation of the crystal that clocks the rtc ? the rtc precision may not be as accurate as expected. the rtc embedded in the stm32f101xx and stm32f103xx comes with a digital clock calibration circuit suitable for manufacturing environments, that allows applications to compensate for crystal and temperature variations. this application note discusses the rtc calibration basics and explains how rtc calibration can be used to improve timekeeping accuracy. www.st.com
contents AN2604 - application note 2/14 contents 1 rtc calibration basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.1 crystal accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.2 methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2 calculating the needed amount of calibration . . . . . . . . . . . . . . . . . . . 10 3 calculating calibration over a temperature range . . . . . . . . . . . . . . . . 11 4 conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 5 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
AN2604 - application note list of tables 3/14 list of tables table 1. calibration table: compensation values in ppm and seconds per month (30 days) . . . . . . . 7 table 2. document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
list of figures AN2604 - application note 4/14 list of figures figure 1. typical crystal accuracy plotted against temperature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 figure 2. rtc calibration clock output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 figure 3. crystal accuracy over a temperature range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
AN2604 - application note rtc calibration basics 5/14 1 rtc calibration basics 1.1 crystal accuracy the term ?quartz-accurate? has become a familiar phrase used to describe the accuracy of many time keeping functions. quartz oscillators provide an accuracy far superior to that of other conventional oscillator designs, but they are not perfect. quartz crystals are sensitive to temperature variations. figure 1 shows the relationship between accuracy (acc), temperature (t) and curvature (k) for a typical 32.768 khz crystal. the curve follows the general formula given below: , where: to = 25 c 5 c k = ?0.040 ppm/c 2 note: the variable k is crystal-dependent, the value indicated here is for the crystal mounted on the stm3210b-eval board. refer to the crystal manufacturer for more details on this parameter. the clocks used in most applications require a high degree of accuracy, and there are several factors involved in achi eving this accuracy. typically most crystals are compensated for by adjusting the load capacitance of the oscillator. this method, though effective, has several disadvantages: 1. it requires external components (trim capacitors) 2. it can increase the oscilla tor current (a major factor in battery-supported applications) instead of this crude analog method, stm32f10xxx products use a digital calibration feature that gives the user software control over the calibration procedure, and make it user- friendly. figure 1. typical crystal accuracy plotted against temperature acc k t to ? () 2 = ?100 ?80 ?60 ?40 ?20 0 20 40 ?30 ?20 ?10 0 10 20 30 40 50 60 70 80 temperature (?c) accuracy (ppm) ai14625
rtc calibration basics AN2604 - application note 6/14 1.2 methodology the rtc of stm32f10xxx products is driven by a quartz crystal-controlled oscillator with a nominal frequency of 32.768 khz. the crystal oscillator is one of the most accu rate circuits to provide a fixed frequency. there are two causes of clock error: 1. temperature variation 2. crystal variation as mentioned previously, most clock chips compensate for crystal frequency and temperature variations by using cumbersome trim capacitors. the stm32f10xxx design employs periodic counter corrections. the digital calibration circuit removes 0 to 127 cycles every 2 20 clock cycles (see figure 2. ). the number of times the pulses are blanked depends upon the value that has been loaded into the seven least sign ificant bits of the bkp?s rtc clock calibration register. since the rtc clock calibration register is in the backup domain, the calibration value is not lost even if the device is powered off provided that a battery is connected to the v bat pin. figure 2. rtc calibration clock output 1. the clock output on the anti_tamp pin is the rtc cloc k before calibration, so its value is not changed by the calibration. each calibration step has the effect of subtracting 1 oscillator cycle every 1 048 576 (2 20 ) actual oscillator cycles. that is, 0. 954(1000000/2 20 ) ppm of adjustment per calibration step in the calibration register. as a result, the os cillator clock can be slowed down from 0 to 121 ppm. table 1 on page 7 shows how many ppm and seconds per month (30 days) each bit represents in real time. oscillator div64 lse lsi hse/128 anti_tamp 512 hz output for frequency test enabled by cco bit in bkp_rtccr register clock calibration cal[6:0]bits in bkp_rtccr register rtc rtcclk 32 768 hz ai14626
AN2604 - application note rtc calibration basics 7/14 table 1. calibration table: compensation values in ppm and seconds per month (30 days) calibration value value in ppm rounded to the nearest ppm value in seconds per month (30 days) rounded to the nearest second calibration value value in ppm rounded to the nearest ppm value in seconds per month (30 days) rounded to the nearest second 00 0 6461 158 11 2 6562 161 22 5 6663 163 33 7 6764 166 4 4 10 68 65 168 5 5 12 69 66 171 6 6 15 70 67 173 7 7 17 71 68 176 8 8 20 72 69 178 9 9 22 73 70 180 10 10 25 74 71 183 11 10 27 75 72 185 12 11 30 76 72 188 13 12 32 77 73 190 14 13 35 78 74 193 15 14 37 79 75 195 16 15 40 80 76 198 17 16 42 81 77 200 18 17 44 82 78 203 19 18 47 83 79 205 20 19 49 84 80 208 21 20 52 85 81 210 22 21 54 86 82 213 23 22 57 87 83 215 24 23 59 88 84 218 25 24 62 89 85 220 26 25 64 90 86 222 27 26 67 91 87 225 28 27 69 92 88 227 29 28 72 93 89 230 30 29 74 94 90 232
rtc calibration basics AN2604 - application note 8/14 31 30 77 95 91 235 32 31 79 96 92 237 33 31 82 97 93 240 34 32 84 98 93 242 35 33 87 99 94 245 36 34 89 100 95 247 37 35 91 101 96 250 38 36 94 102 97 252 39 37 96 103 98 255 40 38 99 104 99 257 41 39 101 105 100 260 42 40 104 106 101 262 43 41 106 107 102 264 44 42 109 108 103 267 45 43 111 109 104 269 46 44 114 110 105 272 47 45 116 111 106 274 48 46 119 112 107 277 49 47 121 113 108 279 50 48 124 114 109 282 51 49 126 115 110 284 52 50 129 116 111 287 53 51 131 117 112 289 54 51 133 118 113 292 55 52 136 119 113 294 56 53 138 120 114 297 57 54 141 121 115 299 58 55 143 122 116 302 59 56 146 123 117 304 60 57 148 124 118 307 61 58 151 125 119 309 table 1. calibration table: compensation values in ppm and seconds per month (30 days) (continued) calibration value value in ppm rounded to the nearest ppm value in seconds per month (30 days) rounded to the nearest second calibration value value in ppm rounded to the nearest ppm value in seconds per month (30 days) rounded to the nearest second
AN2604 - application note rtc calibration basics 9/14 as described above, the stm32f10xxx rtc clock calibration circuit subtracts cycles only from crystal clocks. and based on the fact that the rtc prescaler value is set by default to 32 768, faster crystal frequencies (> 32 768 hz) can be calibrated wh ereas slower crystal frequencies (< 32 768 hz) cannot be compensated for. so only crystal frequencies in the range [32 772, 32 768] can be calibrated. since the crystal frequency may vary about 32.768 khz, a solution may be considered that consists in setting the rtc prescaler to 32 766 (instead of 32 768). the crystal frequency is thus compared to 32 766 instead of 32 768. in this way, a crystal frequency in the range [32 770, 32 766] can be compensated. throughout the rest of the document, the co nsidered rtc prescaler value will be 32 766. 62 59 153 126 120 311 63 60 156 127 121 314 table 1. calibration table: compensation values in ppm and seconds per month (30 days) (continued) calibration value value in ppm rounded to the nearest ppm value in seconds per month (30 days) rounded to the nearest second calibration value value in ppm rounded to the nearest ppm value in seconds per month (30 days) rounded to the nearest second
calculating the needed amount of calibration AN2604 - application note 10/14 2 calculating the needed amount of calibration to establish how much calibration is required in a given application, a method specially suited to manufacturing environments is retained. it involves the use of the rtc clock output mode, which derives a 512 hz signal from the clock divider chain as indicated in figure 2 on page 6 . this signal can be used to measure the accuracy of the crystal oscillator. this method can be divided up into the following steps: 1. enable the low speed external oscillato r (lse), select the l se as the rtc clock source, then enable the rtc clock. 2. enable the rtc clock output with a frequency divided by 64, on the anti_tamp pin for crystal frequency measurement. this is achieved by setting the cco bit in bkp_rtccr. 3. calculate the crystal frequency deviation in ppm. the deviation in ppm can be quickly calculated by dividing the measured deviation from 511.968 hz by 511.968 and, by multiplying the result by 1 million. fi nd the nearest calibration value using table 1 on page 7 . this table is a direct look-up table for calibration values based upon variation values expressed in ppm. 4. load the calibration value in the rtc calibration register to compensate for the crystal deviation. note: to set the rtc prescaler to 32 766, write 32 765 into the rtc prescaler load register. for example, if the frequency measured during the test mode is 511.982 hz, the delta is 0.014. by dividing by 511.968 an d multiplying by 1 million, the re sult is 27.35 ppm. in this case, the nearest compen sation value is 28. the inaccuracy will be reduced from 27.35 ppm (~71 seconds per month) to 0.65 ppm (~1.7 second per month). note: since rtc calibration is based on removing clock cycles, it does not improve counting over short periods of time, it only improves counting over long periods. for example counting a 1/100 s using the rtc will be more accurate without calibration than with calibration. since calibration cycle removal may or not occur duri ng the considered time frame, the resulting value may change significantly. so depending on the application it may be better not to use calibration.
AN2604 - application note calculating calibration over a temperature range 11/14 3 calculating calibration over a temperature range the calibration procedure described so far aims at calculating the correction for a specific temperature. this section provides a procedure for minimizing the frequency variation over a wider temperature range. this involves adjusting the frequency curve so that there is an equal amount of error above and below the zero (0) ppm point. figure 3 on page 11 shows how the frequency error can be minimized over a given temperature range. the variables in the equation: (see section 1.1 on page 5 ) are the following: acc = accuracy, in ppm, of the frequency, at the turnover temperature k = curvature characteristic = ?0.04 ppm/c 2 to = turnover temperature in degrees celsius = 25 c 5 c t = working temperature in degrees celsius for example, if a device shows a deviation of +27 ppm at room temperature, but the operating temperature is 40 c in the application, the equation may be used to calculate the required calibration value as follows: since the accuracy deviation is 18 ppm, the nearest calibration value as indicated in ta bl e 1 on page 7 , is 19. figure 3. crystal accuracy over a temperature range acc k t to ? () 2 = acc 27ppm 0.04ppm ? () c 2 ? () 40 c25 c ? () 2 + = acc 18ppm = ?90 ?80 ?70 ?60 ?50 ?40 ?30 ?20 ?10 0 10 20 30 40 ?30 ?20 ?10 0 10 20 30 40 50 60 70 80 temperature ?c accuracy (ppm) after calibration before calibration ai14629
conclusion AN2604 - application note 12/14 4 conclusion the stm32f10xxx rtc digital clock calibration feature allows the user to adjust the clock accuracy during manufacturing (or later) at minimal cost. this feature also provides a method whereby ?drift? (due to temperature variation) can be corrected and/or anticipated. however, the method described in this applic ation note is applicab le only if the rtc prescaler is set to 32 766 (instead of 32 768).
AN2604 - application note revision history 13/14 5 revision history table 2. document revision history date revision changes 31-aug-2007 1 initial release.
AN2604 - application note 14/14 please read carefully: information in this document is provided solely in connection with st products. stmicroelectronics nv and its subsidiaries (?st ?) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described he rein at any time, without notice. all st products are sold pursuant to st?s terms and conditions of sale. purchasers are solely responsible for the choice, selection and use of the st products and services described herein, and st as sumes no liability whatsoever relating to the choice, selection or use of the st products and services described herein. no license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. i f any part of this document refers to any third party products or services it shall not be deemed a license grant by st for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoev er of such third party products or services or any intellectual property contained therein. unless otherwise set forth in st?s terms and conditions of sale st disclaims any express or implied warranty with respect to the use and/or sale of st products including without limitation implied warranties of merchantability, fitness for a parti cular purpose (and their equivalents under the laws of any jurisdiction), or infringement of any patent, copyright or other intellectual property right. unless expressly approved in writing by an authorized st representative, st products are not recommended, authorized or warranted for use in milita ry, air craft, space, life saving, or life sustaining applications, nor in products or systems where failure or malfunction may result in personal injury, death, or severe property or environmental damage. st products which are not specified as "automotive grade" may only be used in automotive applications at user?s own risk. resale of st products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by st for the st product or service described herein and shall not create or extend in any manner whatsoev er, any liability of st. st and the st logo are trademarks or registered trademarks of st in various countries. information in this document supersedes and replaces all information previously supplied. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners. ? 2007 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia - belgium - brazil - canada - china - czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of AN2604

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X